home *** CD-ROM | disk | FTP | other *** search
- /* Contains the custom unary functions */
-
- #include <SANE.h>
- #include "EqnCompiler.h"
-
- /* Number of custom functions defined */
- #define NUM_CF 2
-
- /* Declaration of custom functions */
- extended saneasin(extended);
- extended saneacos(extended);
-
- /* Array of custom function pointers */
- ProcPtr CFPtr[] = {
- (void *) saneasin,
- (void *) saneacos
- };
-
- /* Array of pointers to custom keywords */
- char *CFKeyword[] = {
- "\pasin",
- "\pacos"
- };
-
- /* The custom functions */
- static int _C[] = {0x3FDE, 0x8000, 0x0000, 0x0000, 0x0000};
- #define C (* (extended *) _C)
- extended saneasin(extended x)
- {
- environment env;
- extended y;
-
- procentry(&env);
- y = fabs(x);
- if (y > C) {
- if (y > 0.5) {
- y = 1 - y;
- y = 2*y - y*y;
- } else y = 1 - y*y;
- y = atan(x/sqrt(y));
- /* may give divide by zero exception */
- setexception(DIVBYZERO, false);
- } else y = x;
- procexit(env);
- return y;
- }
-
- extended saneacos(extended x)
- {
- environment env;
- extended y;
-
- procentry(&env);
- y = 2*atan(sqrt((1-x)/(1+x)));
- /* may give divide by zero exception */
- setexception(DIVBYZERO, false);
- procexit(env);
- return y;
- }
-
- /* look up custom keywords */
- int LookUpCF(char *str, int *result)
- {
- int i;
-
- for (i=0; i<NUM_CF; i++) {
- if (EqualString(str, CFKeyword[i], 0, 1)) {
- *result = UN_FUNC + CUSTOM + i;
- return 0;
- }
- }
- return badTokenErr;
- }
-
-